package com.a1710.utils;

import java.io.UnsupportedEncodingException;
import java.util.Random;

/**
 * 随机
 * @author zhuzg
 *
 */
public class CmsRandomUtils {
	
	/**
	 * 
	 */
	private static char charater[] = new char[26]; 
	// 静态块当中初始化数组
	static {
		for (int i = 'a'; i <= 'z'; i++) {
			charater[i-'a']=(char)i;
		}
	}
	
	
	
	/**
	 *  随机生成英文字符串
	 *  
	 * @param len
	 * @return
	 */
	public static String randomStr(int len) {
		//
		StringBuilder sb = new StringBuilder();
		
		//生成随机对象
		Random random = new Random();
		
		//随机剩n个字符串
		for (int i = 0; i < len; i++) {
			sb.append(charater[random.nextInt(26)]);
		}
		
		return sb.toString();
		
	}
	
	/*private static   String randomCnChar(int len) throws UnsupportedEncodingException {	
	{
		StringBuilder sb=new StringBuilder();
		sb.append(randomCnChar());
		return sb.toString();
	}
	
	 private static  String randomCnChar() throws UnsupportedEncodingException {
		 byte word[] = new byte[2];
			//  0x1A   0x1A+94
			Random random = new Random();
			word[0] = (byte)(0xA1 + 0x10 + random.nextInt(39));
			word[1] = (byte)(0xA1  + random.nextInt(94));
			return new String(word,"GBK");
	 }*/
	
	
}
